home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / wpj1_8.zip / GASH.ZIP / METAFILE / TEST / TESTMET.C < prev    next >
C/C++ Source or Header  |  1993-08-14  |  2KB  |  92 lines

  1. /*
  2.  
  3. TESTMET.C - Tests metafile functions
  4.             (C) 1993, Dennis CHUAH
  5.  
  6. */
  7.  
  8. #define STRICT
  9. #include <windows.h>
  10. #include <windowsx.h>
  11. #include <metafile.h>
  12.  
  13.  
  14. static HMETAFILE hMet;
  15. static char *MetClass = "TestMetaFileClass";
  16.  
  17. LRESULT CALLBACK WindowProc (HWND hWnd, UINT msg, WPARAM wParam,
  18.                              LPARAM lParam);
  19.  
  20. #pragma argsused
  21. int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine,
  22.                     int nCmdShow)
  23.   {METAFILEHEADER mh;
  24.    HMETAFILE hMf;
  25.    WNDCLASS wc;
  26.    HWND hWnd;
  27.    MSG msg;
  28.  
  29.    hMet = GetMetaFileBetter ("GASH1.WMF", &mh);
  30.    hMf = CopyMetaFile (hMet, "GASH-NO.WMF");
  31.    DeleteMetaFile (hMf);
  32.    hMf = CopyMetaFileBetter (hMet, "GASH-YES.WMF", &mh);
  33.    DeleteMetaFile (hMet);
  34.    hMet = hMf;
  35.  
  36.    if (hPrev == NULL)
  37.      {wc.style = CS_HREDRAW | CS_VREDRAW;
  38.       wc.lpfnWndProc = WindowProc;
  39.       wc.cbClsExtra = 0;
  40.       wc.cbWndExtra = 0;
  41.       wc.hInstance = hInstance;
  42.       wc.hIcon = NULL;
  43.       wc.hCursor = LoadCursor (NULL, IDC_ARROW);
  44.       wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  45.       wc.lpszMenuName = NULL;
  46.       wc.lpszClassName = MetClass;
  47.       RegisterClass (&wc);
  48.      }
  49.  
  50.    hWnd = CreateWindow (MetClass, "Test MetaFile functions",
  51.       WS_OVERLAPPEDWINDOW, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
  52.       NULL, NULL, hInstance, NULL);
  53.    ShowWindow (hWnd, nCmdShow);
  54.    UpdateWindow (hWnd);
  55.  
  56.    while (GetMessage (&msg, NULL, 0, 0))
  57.      {TranslateMessage (&msg);
  58.       DispatchMessage (&msg);
  59.      }
  60.  
  61.    DeleteMetaFile (hMet);
  62.    return msg.wParam;
  63.   } // end WinMain
  64.  
  65.  
  66. LRESULT CALLBACK WindowProc (HWND hWnd, UINT msg, WPARAM wParam,
  67.                              LPARAM lParam)
  68.   {PAINTSTRUCT ps;
  69.    HDC hDc;
  70.    RECT rect;
  71.  
  72.    if (msg == WM_PAINT)
  73.      {hDc = BeginPaint (hWnd, &ps);
  74.       GetClientRect (hWnd, &rect);
  75.       SetMapMode (hDc, MM_ANISOTROPIC);
  76.       SetViewportExt (hDc, rect.right, rect.bottom);
  77.       SetViewportOrg (hDc, 0, 0);
  78.       PlayMetaFile (hDc, hMet);
  79.       EndPaint (hWnd, &ps);
  80.       return 0L;
  81.      }
  82.    else if (msg == WM_DESTROY)
  83.      {PostQuitMessage (0);
  84.       return 0L;
  85.      }
  86.  
  87.    return DefWindowProc (hWnd, msg, wParam, lParam);
  88.   } // end WindowProc
  89.  
  90.  
  91.  
  92.